home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / bipl.zip / PROGS.ZIP / ADLCHECK.ICN next >
Text File  |  1992-09-28  |  3KB  |  102 lines

  1. ############################################################################
  2. #
  3. #    File:     adlcheck.icn
  4. #
  5. #    Subject:  Program to check for bad address list data
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     December 30, 1991
  10. #
  11. ###########################################################################
  12. #
  13. #    This program checks address lists for correctness.
  14. #
  15. #    There are five options:
  16. #
  17. #    -s    Check state (U.S. labels only)
  18. #    -z    Check ZIP code (U.S. labels only)
  19. #    -c    Check country name (a very heuristic check)
  20. #    -a    Check all of the above
  21. #    -d    Report addresses that exceed "standard dimensions" for labels:
  22. #           40 character line length, 8 lines per entry
  23. #
  24. ############################################################################
  25. #
  26. #  See also: address.doc, adlcount.icn, adlfilter.icn, adllist.icn,
  27. #     adlsort,icn, labels.icn
  28. #
  29. #  Links: adlutils, options
  30. #
  31. ############################################################################
  32.  
  33. link adlutils, options
  34.  
  35. procedure main(args)
  36.    local opts, choice, item, badchar, print, states, i, line, dim, add
  37.  
  38.    states := set(["AK", "AL", "AR", "AS", "AZ", "CA", "CO", "CT", "DC",
  39.       "DE", "FL", "FM", "GA", "GU", "HI", "IA", "ID", "IL", "IN", "KS",
  40.       "KY", "LA", "MA", "MD", "ME", "MH", "MI", "MN", "MO", "MP", "MS",
  41.       "MT", "NC", "ND", "NE", "NH", "NJ", "NM", "NV", "NY", "OH", "OK",
  42.       "ON", "OR", "PA", "PR", "PW", "RI", "SC", "SD", "TN", "TX", "UT",
  43.       "VA", "VT", "WA", "WI", "WV", "WY"])
  44.  
  45.    print := ""
  46.  
  47.    badchar := ~&ucase -- ' .'        # very heuristic country name check
  48.  
  49.    opts := options(args,"acszd")
  50.    if \opts["a"] then {            # if -a, do all
  51.       opts["a"] := &null
  52.       every opts[!"csz"] := 1
  53.       }
  54.    if \opts["d"] then dim := write(1)        # dimension check
  55.  
  56.    while add := nextadd() do {
  57.       add.text ? {
  58.          i := 0
  59.          while line := tab(upto('\n') | 0) do {
  60.             i +:= 1
  61.             if *line > 40 then print ||:= "o"
  62.             move(1) | break
  63.             }
  64.          if i > 8 then print ||:= "o"
  65.          }
  66.  
  67.       every \opts[choice := !"csz"] do
  68.          case choice of {
  69.          "c":  {            # check country name
  70.             get_country(add) ? {
  71.                if upto(badchar) then {
  72.                   print ||:= choice
  73.                   }
  74.                }
  75.             }
  76.          "s":  {            # check state
  77.             if not member(states,get_state(add)) then {
  78.                print ||:= choice
  79.                }
  80.             }
  81.          "z":  {
  82.             if get_zipcode(add) == "9999999999" then {
  83.                print ||:= choice
  84.                }
  85.             }
  86.          }
  87.       if *print > 0 then {
  88.          every choice := !print do
  89.             write("*** ",case choice of {
  90.                "c":  "bad country name"
  91.                "s":  "bad state abbreviation"
  92.                "z":  "bad ZIP code"
  93.                "o":  \dim & "size exceeds label dimensions"
  94.                })
  95.          write()
  96.          writeadd(add)
  97.          print := ""
  98.          }
  99.    }
  100.  
  101. end
  102.